// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  traceUser: true,
  env:'aaa111-9gh9fp5ieac4de5d'
})

const db = cloud.database()

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  try {
    await db.collection('follow').add({
      data: {
        _openid: wxContext.OPENID,
        follow: event.follow
      }
    })
    return true
  } catch(e) {
    return false
  }
}